#include "qcorewidgetplugin.h"

#include "qmywidget.h"
#include "qmylineedit.h"
#include "qmylabel.h"
#include "qmyframe.h"
#include "qmypushbutton.h"
#include "qmycheckbox.h"
#include "qmyradiobutton.h"
#include "qmylcdnumber.h"
#include "qmyspinbox.h"
#include "qmydoublespinbox.h"
#include "qmytimeedit.h"
#include "qmydateedit.h"
#include "qmydatetimeedit.h"
#include "qmyprogressbar.h"
#include "qmyslider.h"
#include "qmydial.h"
#include "qmyscrollbar.h"
#include "qkeyboardbutton.h"

#include <qplugin.h>
#include <QVariant>

QCoreWidgetPlugin::QCoreWidgetPlugin()
{
}

QWidget* QCoreWidgetPlugin::createWidget(const QString &widget)
{
    QWidget* ret=NULL;
    if(widget=="QWidget")
    {
        ret=new QMyWidget;
    }
    else if(widget=="QLineEdit")
    {
        ret=new QMyLineEdit;
    }
    else if(widget=="QLabel")
    {
        ret=new QMyLabel;
    }
    else if(widget=="QFrame")
    {
        ret=new QMyFrame;
    }
    else if(widget=="QPushButton")
    {
        ret=new QMyPushButton;
    }
    else if(widget=="QRadioButton")
    {
        ret=new QMyRadioButton;
    }
    else if(widget=="QCheckBox")
    {
        ret=new QMyCheckBox;
    }
    else if(widget=="QLCDNumber")
    {
        ret=new QMyLCDNumber;
    }
    else if(widget=="QSpinBox")
    {
        ret=new QMySpinBox;
    }
    else if(widget=="QDoubleSpinBox")
    {
        ret=new QMyDoubleSpinBox;
    }
    else if(widget=="QTimeEdit")
    {
        ret=new QMyTimeEdit;
    }
    else if(widget=="QDateEdit")
    {
        ret=new QMyDateEdit;
    }
    else if(widget=="QDateTimeEdit")
    {
        ret=new QMyDateTimeEdit;
    }
    else if(widget=="QProgressBar")
    {
        ret=new QMyProgressBar;
    }
    else if(widget=="QSlider")
    {
        ret=new QMySlider;
    }
    else if(widget=="QDial")
    {
        ret=new QMyDial;
    }
    else if(widget=="QScrollBar")
    {
        ret=new QMyScrollBar;
    }
    else if(widget=="QKeyboardButton")
    {
        ret=new QKeyboardButton;
    }

    if(ret!=NULL)
    {
        ret->setProperty("type",widget);
        ret->setProperty("plugin",pluginName());
    }
    return ret;
}


QString QCoreWidgetPlugin::pluginName()
{
    return "Core.Widget.Plugin";
}


QStringList QCoreWidgetPlugin::supportWidgets()
{
    QStringList list;

    list<<"QWidget"<<"QLineEdit"<<"QLabel"<<"QFrame"<<"QPushButton"<<"QKeyboardButton"
       <<"QRadioButton"<<"QCheckBox"<<"QLCDNumber"<<"QSpinBox"
      <<"QDoubleSpinBox"<<"QDateTimeEdit"<<"QDateEdit"<<"QTimeEdit"
     <<"QProgressBar"<<"QSlider"<<"QDial"<<"QScrollBar";

    return list;
}

SHAREDLIB::WidgetInfo QCoreWidgetPlugin::widgetInfo(const QString &widget)
{
    SHAREDLIB::WidgetInfo info;

    if(widget=="QWidget")
    {
        info.m_name=tr("Widget");
        info.m_icon=":/images/widget.png";
        info.m_category=tr("Containers");
    }
    else if(widget=="QLineEdit")
    {
        info.m_name=tr("LineEdit");
        info.m_icon=":/images/lineedit.png";
        info.m_category=tr("Input Widgets");
    }
    else if(widget=="QLabel")
    {
        info.m_name="Label";
        info.m_icon=":/images/label.png";
        info.m_category=tr("Display Widgets");
    }
    else if(widget=="QFrame")
    {
        info.m_name="Frame";
        info.m_icon=":/images/frame.png";
        info.m_category=tr("Containers");
    }
    else if(widget=="QPushButton")
    {
        info.m_name="Button";
        info.m_icon=":/images/pushbutton.png";
        info.m_category=tr("Buttons");
    }
    else if(widget=="QKeyboardButton")
    {
        info.m_name="Keyboard Button";
        info.m_icon=":/images/pushbutton.png";
        info.m_category=tr("Buttons");
    }
    else if(widget=="QRadioButton")
    {
        info.m_name="Radio";
        info.m_icon=":/images/radiobutton.png";
        info.m_category=tr("Buttons");
    }
    else if(widget=="QCheckBox")
    {
        info.m_name="CheckBox";
        info.m_icon=":/images/checkbox.png";
        info.m_category=tr("Buttons");
    }
    else if(widget=="QLCDNumber")
    {
        info.m_name="LCDNumber";
        info.m_icon=":/images/lcdnumber.png";
        info.m_category=tr("Display Widgets");
    }
    else if(widget=="QSpinBox")
    {
        info.m_name="SpinBox";
        info.m_icon=":/images/spinbox.png";
        info.m_category=tr("Input Widgets");
    }
    else if(widget=="QDoubleSpinBox")
    {
        info.m_name="SpinBox";
        info.m_icon=":/images/doublespinbox.png";
        info.m_category=tr("Input Widgets");
    }
    else if(widget=="QDateTimeEdit")
    {
        info.m_name="DateTime";
        info.m_icon=":/images/datetimeedit.png";
        info.m_category=tr("Input Widgets");
    }
    else if(widget=="QDateEdit")
    {
        info.m_name="Date";
        info.m_icon=":/images/dateedit.png";
        info.m_category=tr("Input Widgets");
    }
    else if(widget=="QTimeEdit")
    {
        info.m_name="Time";
        info.m_icon=":/images/timeedit.png";
        info.m_category=tr("Input Widgets");
    }
    else if(widget=="QProgressBar")
    {
        info.m_name="ProgressBar";
        info.m_icon=":/images/progress.png";
        info.m_category=tr("Display Widgets");
    }
    else if(widget=="QSlider")
    {
        info.m_name="Slider";
        info.m_icon=":/images/hslider.png";
        info.m_category=tr("Input Widgets");
    }
    else if(widget=="QDial")
    {
        info.m_name="Dial";
        info.m_icon=":/images/dial.png";
        info.m_category=tr("Input Widgets");
    }
    else if(widget=="QScrollBar")
    {
        info.m_name="ScrollBar";
        info.m_icon=":/images/hscrollbar.png";
        info.m_category=tr("Input Widgets");
    }
    info.m_pluginName=pluginName();
    return info;
}

Q_EXPORT_PLUGIN2(QCoreWidgetPlugin,QCoreWidgetPlugin)
